<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/commons/inc.jsp" %>

<h3 id="navTitleId">中医证候调查表</h3>

<script>
function show(){
	var a = '<s:property value='symptomsResult.answer'/>';
	if(a!=null){
		a = a.split(",");
		for(var i=1;i<=a.length-5;i++){
			$('answer'+i+"-"+a[i-1].trim()).checked = true;
		}
		//舌色、舌形、胎色、胎质、脉象
		for(var i=a.length-4;i<=a.length;i++){	 
			 var obj = document.getElementsByName('answer'+i);
			 var value = a[i-1].trim();
			 for(var m=0; m<obj.length; m++){
				 if((obj[m].value & value) == obj[m].value ){
					 obj[m].checked = true; 
			     }
			 }	    	
		}
	}
}
</script>
<body id="body">

<%@include file="/commons/showmessage.jsp" %>

<form name="symptomform" id="symptomform" method="post" action="${contextPath}/survey/survey.action?method=saveEditSymptomsSurvey">
	<s:hidden name="symptomsResult.seqid" id="symptomsResult.seqid"></s:hidden>
	<s:hidden name="symptomsResult.patientid" id="symptomsResult.patientid"></s:hidden>
	<s:hidden name="answer" id="answer"></s:hidden>
	<s:hidden name="result" id="result"></s:hidden>
	<s:hidden name="patientid" id="patientid"></s:hidden>
	
	<table border="0" cellspacing="1" cellpadding="0" class="formTable" width="100%" >
		<thead>
			<tr><td width="100%" align="left" class="form-th" colspan="6">糖尿病中医证候自评量表</td></tr>
			<tr><td width="100%" align="left" class="form-th" colspan="6">请您根据最近一周的情况，回答是否有以下症状及其严重程度</td></tr>
		</thead>
		 
		 <tbody> 
		  <s:iterator value="symptomsSurvey" id="ind" status="st">	
		  	<tr>
		  		<td align="center" class="form-td"><s:property value="#st.index+1"/></td>
				<td align="left" class="form-td">${symptomname}</td>
				<s:if test="symptomname=='舌色'">
					<td align="left" class="form-td" colspan="4">
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-0" value="3"/><font style="vertical-align:bottom;">淡红</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-1" value="1"/><font style="vertical-align:bottom;">淡白</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-2" value="2"/><font style="vertical-align:bottom;">红</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-3" value="4"/><font style="vertical-align:bottom;">紫暗 </font>
					</td>
				</s:if>
				<s:elseif test="symptomname=='舌形'">
					<td align="left" class="form-td" colspan="4">
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-1" value="1"/><font style="vertical-align:bottom;">胖大</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-2" value="2"/><font style="vertical-align:bottom;">齿痕</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-3" value="4"/><font style="vertical-align:bottom;">瘀斑瘀点 </font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-4" value="8"/><font style="vertical-align:bottom;">裂纹</font>
					</td>
				</s:elseif>
				<s:elseif test="symptomname=='苔色'">
					<td align="left" class="form-td" colspan="4">
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-1" value="1"/><font style="vertical-align:bottom;">白</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-2" value="2"/><font style="vertical-align:bottom;">黄</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-3" value="4"/><font style="vertical-align:bottom;">灰 </font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-4" value="8"/><font style="vertical-align:bottom;">黑</font>
					</td>
				</s:elseif>
				<s:elseif test="symptomname=='苔质'">
					<td align="left" class="form-td" colspan="4">
				     <input type="checkbox" name="answer${sympid}" id="answer${sympid}-1" value="1"/><font style="vertical-align:bottom;">薄苔</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-2" value="2"/><font style="vertical-align:bottom;">腻苔</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-3" value="4"/><font style="vertical-align:bottom;">少苔 </font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-4" value="8"/><font style="vertical-align:bottom;">剥苔</font>
					</td>
				</s:elseif>
				<s:elseif test="symptomname=='脉象'">
					<td align="left" class="form-td" colspan="4">
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-1" value="1"/><font style="vertical-align:bottom;">平</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-2" value="2"/><font style="vertical-align:bottom;">细</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-3" value="4"/><font style="vertical-align:bottom;">弱 </font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-4" value="8"/><font style="vertical-align:bottom;">弦</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-5" value="16"/><font style="vertical-align:bottom;">滑</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-6" value="32"/><font style="vertical-align:bottom;">涩</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-7" value="64"/><font style="vertical-align:bottom;">数 </font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-8" value="128"/><font style="vertical-align:bottom;">迟</font>
					 <input type="checkbox" name="answer${sympid}" id="answer${sympid}-9" value="256"/><font style="vertical-align:bottom;">结代</font>
					</td>
				</s:elseif>
				<s:else>
					<td align="left" class="form-td"><input style="vertical-align:sub;" type="radio" name="answer${sympid}" id="answer${sympid}-0" value="0"/><font style="vertical-align:sub;">无</font></td>
					<td align="left" class="form-td"><input style="vertical-align:sub;" type="radio" name="answer${sympid}" id="answer${sympid}-1" value="1"/><font style="vertical-align:sub;">轻</font></td>
					<td align="left" class="form-td"><input style="vertical-align:sub;" type="radio" name="answer${sympid}" id="answer${sympid}-2" value="2"/><font style="vertical-align:sub;">中</font></td>	
					<td align="left" class="form-td"><input style="vertical-align:sub;" type="radio" name="answer${sympid}" id="answer${sympid}-3" value="3"/><font style="vertical-align:sub;">重</font></td>		
				</s:else>
			</tr>
	 	</s:iterator>
	 		<script>show()</script>
	 		 <tr><td align="left" class="form-td">证型：</td>
	 		 	<td align="left" class="form-td" colspan="5"><s:property value='symptomsResult.result'/></td></tr>
		</tbody>
	</table>	  
	<table>
		<tr>
			<td align="center" colspan="5">
			<input type="reset" value="重置">
		    <input type="button" onclick="saveEdit();" value="保存"></td>
		</tr>
	</table>
</form>

<%@include file="/commons/tableSel.jsp" %>

</body>

<style type="text/css">
body {
	height: 100%;
	width: 100%;
}
</style>

<script>
function saveEdit(){
	if(!Validator.Validate($('symptomform'),3)){
		return;
	}	
	var c = "";
	var result="";
	var length = '<s:property value='symptomsSurvey.size()'/>';
	var z = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
	var x = new Array('气虚','血虚','阴虚','阳虚','风','湿','燥','热','痰','血瘀','气滞','肝','心','脾','肺','肾');

	var xm_xt=-1;
	var xm_fz=-1;
	<s:iterator value="symptomsSurvey" id="ind" status="st">
		var name = '<s:property value='#ind.symptomname'/>';
		var i = '<s:property value='#st.index+1'/>';
		var r = document.getElementsByName("answer"+i);
		
		var value="";	
		if(r!=null){
			if(i<=length-5){
				var flag = false;
			 	for(var j=0;j<r.length;j++){
			 		if(r[j].checked){
			 			value = r[j].value;
						flag = true;
					}
			 	}
			 	if(!flag){
				 	alert("请填写完整：第"+ i +"题");
				 	return;
			 	}
			}else{ //舌色、舌形、胎色、胎质、脉象	
				var invalue = 0;
				for(var j=0;j<r.length;j++){
			 		if(r[j].checked){
			 			invalue += parseInt(r[j].value);
					}else{
						invalue += 0;
					}
			 	}
				value = invalue;
			}
		}
		if(value!=""){
			c += value +",";
		}
		if(name=='没有力气，容易累' || name=='讲话声音低弱' || name=='稍微活动后气短气急' || name=='容易感冒'){
			z[0] += parseInt(value);
		}else if(name=='记忆力减退' || name=='蹲、坐、躺站起时头晕眼花'|| name=='心慌'|| name=='口唇或指甲颜色淡'){
			z[1] += parseInt(value);
		}else if(name=='手脚发热或自觉低热，面红发烫' || name=='身体消瘦'|| name=='睡觉时出汗'|| name=='口干或喉咙干燥'){
			z[2] += parseInt(value);
		}else if(name=='怕冷' || name=='手脚发凉'|| name=='浮肿'|| name=='小便排出无力，小便不通畅'){
			z[3] += parseInt(value);
		}else if(name=='手脚发抖' || name=='肢体麻木'|| name=='皮肤发痒'|| name=='经常发风疹、红疹'){
			z[4] += parseInt(value);
		}else if(name=='大便不爽，排不尽' || name=='头或身体沉重'|| name=='口中发粘'|| name=='舌苔厚'){
			z[5] += parseInt(value);
		}else if(name=='口干或咽喉干燥' || name=='眼睛干涩'|| name=='皮肤干燥'|| name=='大便干燥坚硬，排出困难'){
			z[6] += parseInt(value);
		}else if(name=='怕热' || name=='口渴，喝水多'|| name=='肚子容易饿，吃得多'|| name=='小便少或颜色黄'){
			z[7] += parseInt(value);
		}else if(name=='喉中有痰' || name=='头晕伴恶心'|| name=='舌苔厚'|| name=='肚子大或身体胖'){
			z[8] += parseInt(value);
		}else if(name=='固定疼痛或刺痛' || name=='皮肤粗糙脱屑'|| name=='口唇、舌头或指甲颜色发暗发紫'|| name=='肢体麻木'){
			z[9] += parseInt(value);
		}else if(name=='喜欢叹气或叹气后感觉舒服' || name=='胸闷或腹胀'|| name=='嗳气或打嗝'|| name=='心情不好'){
			z[10] += parseInt(value);
		}else if(name=='心情不好'|| name=='看东西模糊'|| name=='头胀或头痛'){
			z[11] += parseInt(value);
		}else if(name=='胸闷或心痛' || name=='心慌'|| name=='失眠'){
			z[12] += parseInt(value);
		}else if(name=='大便稀或不成形，次数多' || name=='体重减轻'|| name=='没有胃口'){
			z[13] += parseInt(value);
		}else if(name=='口渴，喝水多' || name=='白天容易出汗'|| name=='容易感冒'){
			z[14] += parseInt(value);
		}else if(name=='腰、膝盖、下肢酸痛，无力' || name=='小便次数多或小便量多'|| name=='耳鸣或耳聋'){
			z[15] += parseInt(value);
		}else if(name=='胸闷'){
			if(xm_xt==-1){
				xm_xt=parseInt(value);
			}else{
				var temp=parseInt(value);
				if(xm_xt<temp){
					z[12] += temp;
				}else{
					z[12] += xm_xt;
				}
			}
			
			if(xm_fz==-1){
				xm_fz=parseInt(value);
			}else{
				var temp=parseInt(value);
				if(xm_fz<temp){
					z[10] += temp;
				}else{
					z[10] += xm_fz;
				}
			}
		}else if(name=='心痛'){
			if(xm_xt==-1){
				xm_xt=parseInt(value);
			}else{
				var temp=parseInt(value);
				if(xm_xt<temp){
					z[12] += temp;
				}else{
					z[12] += xm_xt;
				}
			}
		}else if(name=='腹胀'){
			if(xm_fz==-1){
				xm_fz=parseInt(value);
			}else{
				var temp=parseInt(value);
				if(xm_fz<temp){
					z[10] += temp;
				}else{
					z[10] += xm_fz;
				}
			}
		}
		
 	</s:iterator>
 	for(var i=0;i<z.length;i++){
 	 	if(z[i]>=4){
 	 	 	if(z[i]<=6){
 	 	 		result += x[i] + "(轻);";
 	 	 	}else if(z[i]<=9){
 	 	 		result += x[i] + "(中);";
 	 	 	}else{
 	 	 		result += x[i] + "(重);";
 	 	 	}
 	 	}
 	}
	if(c!=""){
		c = c.substring(0,c.length-1);
	}
	if(result==""){
		result = "无";
	}
	$('symptomform').answer.value = c;
	$('symptomform').result.value = result;
	$('symptomform').submit();
}
</script>